<?php

namespace App\Admin\Controllers\Common;

use App\Models\CommonAppVersion;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class AppVersionController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = 'App信息';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new CommonAppVersion());

        $grid->column('id', ___('table.zy_common_app_version.Id'));
        $grid->column('version', ___('table.zy_common_app_version.Version'));
        $grid->column('build', ___('table.zy_common_app_version.Build'));
        $grid->column('force', ___('table.zy_common_app_version.Force'));
        $grid->column('details', ___('table.zy_common_app_version.Details'));
        $grid->column('create_time', ___('table.zy_common_app_version.Create time'));
        $grid->column('update_time', ___('table.zy_common_app_version.Update time'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(CommonAppVersion::findOrFail($id));

        $show->field('id', ___('table.zy_common_app_version.Id'));
        $show->field('version', ___('table.zy_common_app_version.Version'));
        $show->field('build', ___('table.zy_common_app_version.Build'));
        $show->field('force', ___('table.zy_common_app_version.Force'));
        $show->field('details', ___('table.zy_common_app_version.Details'));
        $show->field('create_time', ___('table.zy_common_app_version.Create time'));
        $show->field('update_time', ___('table.zy_common_app_version.Update time'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new CommonAppVersion());

        $form->text('version', ___('table.zy_common_app_version.Version'));
        $form->number('build', ___('table.zy_common_app_version.Build'));
        $form->switch('force', ___('table.zy_common_app_version.Force'));
        $form->textarea('details', ___('table.zy_common_app_version.Details'));
        $form->number('create_time', ___('table.zy_common_app_version.Create time'));
        $form->number('update_time', ___('table.zy_common_app_version.Update time'));

        return $form;
    }
}
